<template>
  <div class="common-layout">
    <el-container>
      <el-aside width="200px">
        <Menu></Menu>
      </el-aside>
      <el-container>
        <el-header>
          <Header></Header>
        </el-header>
        <el-main class="content">
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import Header from "@/components/Header.vue"
import Menu from "@/components/Menu.vue"
import {useStore} from 'vuex'
import {ajax} from '@/api'
import {reactive,toRefs,onMounted,ref,computed} from "vue"
export default {
  components:{
      Header,
      Menu
  },
  setup(props) {
     const store=useStore()
     const getUserinfo = async()=>{
        let res = await ajax.getusernfo()
        //存储用户信息在vuex
        console.log(res.userInfo[0]);
         store.commit('changeUserInfo',res.userInfo[0])
      }
      const userInfo=computed(()=>store.state.userInfo)
      
     onMounted(() => {
       getUserinfo()
     })

  }
}
</script>

<style lang="scss" scoped>

.common-layout{
  width: 100%;
  height: 100%;

  .el-container{
    width: 100%;
    height: 100%;
    .el-aside{
      background: #304156;
      height: 100%;
    }
    .el-header{
      background: #b3c0d1;
      display: flex;
      align-items: center;
      flex-direction: row-reverse;
    }
    .el-main{
      background: #e9eef3;

    }
  }
}
  
</style>